package cn.web.web_module.updateweb;

import cn.itcast.util.ResponseEntity;
import cn.web.web_module.service.AutomaticSendService;
import cn.web.web_module.service.impl.AutomaticSendImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: 张松
 * @Description:    获取下单用户和离用户最近距离的骑手
 * @Date: Created in 11:03 2020/6/30
 * @Modified By:
 */

@RestController
@RequestMapping("automaticSend")
@Slf4j
public class AutomaticSendController {

    @Resource
    private AutomaticSendImpl automaticSend;

    @RequestMapping("UserAndHorsemanDistance")
    public ResponseEntity getUserAndHorsemanDistance(@RequestBody Map<String,Double> latAndLon){
        try {
            Map<String, Object> horsemanAndUserDistance = automaticSend.getHorsemanAndUserDistance(latAndLon);
            if (!horsemanAndUserDistance.isEmpty()||horsemanAndUserDistance.size()!=0)return new ResponseEntity(horsemanAndUserDistance);
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ResponseEntity().error_300();

    }

}
